package top.bugger168.content.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.bugger168.content.model.po.CourseTeacher;
import top.bugger168.content.service.CourseTeacherService;

import javax.annotation.Resource;
import java.util.List;

/**
 * 课程教师编辑接口
 *
 * @author wanghaidong
 * @date 2023/08/28
 */
@Api(value = "课程教师编辑接口",tags = "课程教师编辑接口")
@RestController
public class CourseTeacherController {
    @Resource
    CourseTeacherService courseTeacherService;

    @ApiOperation("查询教师信息")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> listCourseTeacher(@PathVariable Long courseId){
        return courseTeacherService.listTeacher(courseId);
    }

    @ApiOperation("添加/修改教师信息")
    @PostMapping("/courseTeacher")
    public CourseTeacher addCourseTeacher(@RequestBody @Validated CourseTeacher courseTeacher){
        return courseTeacherService.saveTeacher(courseTeacher);
    }


    @ApiOperation("删除教师信息")
    @DeleteMapping("/courseTeacher/course/{courseId}/{teacherId}")
    public void deleteCourseTeacher(@PathVariable Long courseId,@PathVariable Long teacherId){
        courseTeacherService.removeTeacher(courseId,teacherId);
    }
}
